import 'package:json2dart_safe/json2dart.dart';
import 'package:pornhub_app/model/community/community_content_model.dart';
import 'package:pornhub_app/model/community/community_video_model.dart';
import 'package:pornhub_app/model/community/topic_model.dart';

class CommunityModel {
  String? checkAt; //审核时间
  String? cityName; //城市名
  int? commentNum; //评论数
  String? content; //动态内容
  List<TopicModel>? coteries; //话题
  String? createdAt; //创建时间
  int? dynamicId; //动态id
  int? dynamicType; //动态类型:1-图文 2-视频
  int? dynamicImgType; //动态图片类型：1-短图，2-长图
  List<String>? dynamicImg; //动态图片
  CommunityVideoModel? video; //视频
  int? fakeLikes; //伪造点赞次数
  int? realLikes; //真实点赞次数
  bool? isLike; //是否点赞
  bool? isFavorite; //是否收藏
  bool? isAttention; // 是否关注
  bool? isUnlock; // 是否解锁
  bool? isUpUser; // 是否UP主
  double? gold; //价格
  double? imgHeight; //图片高度
  double? imgWidth; // 图片宽度
  int? status; //状态：1-未审核 2-已通过 3-已拒绝
  String? notPass; //审核不通过原因
  int? jumpType; //跳转类型 1、内部跳转 2、外部跳转
  String? jumpUrl; //跳转地址
  int? topSortNum; //置顶排序（大于0显示置顶标识）
  int? userId; //用户ID
  String? nickName; //用户昵称
  String? logo; //头像
  int? gender; //用户性别 1-女,2-男,3-保密
  int? vipType; //用户会员类型 (0-普通用户; 1-体验卡; 2-浅网会员; 5-萝莉岛会员; 8-至尊会员)

  CommunityModel({
    this.checkAt,
    this.cityName,
    this.commentNum,
    this.content,
    this.coteries,
    this.createdAt,
    this.dynamicId,
    this.dynamicType,
    this.dynamicImgType,
    this.dynamicImg,
    this.video,
    this.fakeLikes,
    this.realLikes,
    this.isLike,
    this.isFavorite,
    this.isAttention,
    this.isUnlock,
    this.isUpUser,
    this.gold,
    this.imgHeight,
    this.imgWidth,
    this.status,
    this.notPass,
    this.jumpType,
    this.jumpUrl,
    this.topSortNum,
    this.userId,
    this.nickName,
    this.logo,
    this.gender,
    this.vipType,
  });

  Map<String, dynamic> toJson() {
    return <String, dynamic>{}
      ..put('checkAt', checkAt)
      ..put('cityName', cityName)
      ..put('commentNum', commentNum)
      ..put('content', content)
      ..put('coteries', coteries)
      ..put('createdAt', createdAt)
      ..put('dynamicId', dynamicId)
      ..put('dynamicType', dynamicType)
      ..put('dynamicImgType', dynamicImgType)
      ..put('dynamicImg', dynamicImg)
      ..put('video', video)
      ..put('fakeLikes', fakeLikes)
      ..put('realLikes', realLikes)
      ..put('isLike', isLike)
      ..put('isFavorite', isFavorite)
      ..put('isAttention', isAttention)
      ..put('isUnlock', isUnlock)
      ..put('isUpUser', isUpUser)
      ..put('gold', gold)
      ..put('imgHeight', imgHeight)
      ..put('imgWidth', imgWidth)
      ..put('status', status)
      ..put('notPass', notPass)
      ..put('jumpType', jumpType)
      ..put('jumpUrl', jumpUrl)
      ..put('topSortNum', topSortNum)
      ..put('userId', userId)
      ..put('nickName', nickName)
      ..put('logo', logo)
      ..put('gender', gender)
      ..put('vipType', vipType);
  }

  CommunityModel.fromJson(Map<String, dynamic> json) {
    checkAt = json.asString('checkAt');
    cityName = json.asString('cityName');
    commentNum = json.asInt('commentNum');
    content = json.asString('content');
    coteries = json.asList<TopicModel>('coteries', TopicModel.toBean);
    createdAt = json.asString('createdAt');
    dynamicId = json.asInt('dynamicId');
    dynamicType = json.asInt('dynamicType');
    dynamicImgType = json.asInt('dynamicImgType');
    dynamicImg = json.asList<String>('dynamicImg');
    video = json.asBean('video',
        (v) => CommunityVideoModel.fromJson(Map<String, dynamic>.from(v)));
    fakeLikes = json.asInt('fakeLikes');
    realLikes = json.asInt('realLikes');
    isLike = json.asBool('isLike');
    isFavorite = json.asBool('isFavorite');
    isAttention = json.asBool('isAttention');
    isUnlock = json.asBool('isUnlock');
    isUpUser = json.asBool('isUpUser');
    gold = json.asDouble('gold');
    imgHeight = json.asDouble('imgHeight');
    imgWidth = json.asDouble('imgWidth');
    status = json.asInt('status');
    notPass = json.asString('notPass');
    jumpType = json.asInt('jumpType');
    jumpUrl = json.asString('jumpUrl');
    topSortNum = json.asInt('topSortNum');
    userId = json.asInt('userId');
    nickName = json.asString('nickName');
    logo = json.asString('logo');
    gender = json.asInt('gender');
    vipType = json.asInt('vipType');
  }

  static CommunityModel toBean(dynamic json) => CommunityModel.fromJson(json);
}
